
//导航高亮
function highlight_subnav(url){
    $('.nav-list').find('a[href="'+url+'"]').closest('li').addClass('active').parent().parent().addClass('active open');
}

/**
 * 公共表格全选方法
 */
$(document).on('click', 'th input:checkbox' , function(){
    var that = this;
    $(this).closest('table').find('tr > td:first-child input:checkbox')
        .each(function(){
            this.checked = that.checked;
            $(this).closest('tr').toggleClass('selected');
        });
});

/* 激活状态操作 */
$(function () {
    $('body').on('click','.active-btn',function () {
        var $url = this.href,
            val = $(this).data('id'),
            $btn=$(this);
        $.post($url, {id: val}, function (data) {
            if (data.code==1) {
                if (data.msg == '关闭') {
                    $btn.children('span').html(data.msg).attr('title','关闭').removeClass('label-success').addClass('label-danger');
                    return false;
                } else {
                    $btn.children('span').html(data.msg).attr('title','开启').removeClass('label-danger').addClass('label-success');
                    return false;
                }
            } else {
                layer.alert(data.msg, {icon: 5});
            }
        }, "json");
        return false;
    });
});

$(function () {
    // $('body').on('click','.dropdown-menu li a',function () {
    //     $(this).addClass('active').parents('li').siblings().find('a').removeClass('active');
    // });
    // $('body').on('mouseover','.dropdown-menu li a',function () {
    //     $(this).addClass('active').parents('li').siblings().find('a').removeClass('active');
    // });
    // $('.dropdown-menu li a').on('click',function () {
    //     $(this).addClass('active').parents('li').siblings().find('a').removeClass('active');
    // });
    // $('.dropdown-menu li a').on('mouseover',function () {
    //     $(this).addClass('active').parents('li').siblings().find('a').removeClass('active');
    // });
});
/**
 * 公共删除方法
 * @param url
 */
function opendel(url){
    layer.confirm('确定删除？', {
        skin: 'layui-layer-lan', //样式类名
        btn: ['真的','假的'] //按钮
    }, function(){
        $.post(url,function(data){
            if(data.status==2){
                var ico=2;
            }
            if(data.status==1){
                var ico=1;
            }
            if(data.status==0){
                var ico=2;
            }
            layer.msg(data.info, {
                icon: ico,
                time:2000,
            },function(){
                history.go(0);
            });
        });
    }, function(){
        layer.msg('下次不要这么调皮了', {
            icon: 2,
        });
    });
}
/**
 * 公共删除方法
 * @param url
 */
function opendel2(url){
    layer.confirm('确定删除？', {
        skin: 'layui-layer-lan', //样式类名
        btn: ['确定','取消'] //按钮
    }, function(){
        $.post(url,function(data){
            if(data.code==1){
                var ico=1;
            }
            if(data.code==0){
                var ico=2;
            }
            layer.msg(data.msg, {
                icon: ico,
                time:2000,
            },function(){
                history.go(0);
            });
        });
    }, function(){
        layer.msg('下次不要这么调皮了', {
            icon: 2,
        });
    });
}
//失败跳转
function complete(data) {
    if (data.code == 1) {
        layer.alert(data.msg, {icon: 6}, function (index) {
            layer.close(index);
            window.location.href = data.url;
        });
    } else {
        layer.alert(data.msg, {icon: 5}, function (index) {
            layer.close(index);
            window.location.href = data.url;
        });
        return false;
    }
}
$(function () {
    $('body').on('click','.confirm-rst-btn',function () {
        var $url = this.href,
            $info = $(this).data('info');
            layer.confirm($info, {icon: 3}, function (index) {
            layer.close(index);
            $.post($url, {}, function (data) {
                layer.alert(data.msg, {icon: 6});
            }, "json");
        },function (index) {
            layer.msg('取消');
        });
        return false;
    });
});
$(document).keyup(function (event) {
    if (event.keyCode == 13) {
        $("#submit").trigger("click");
    }
});

//新增和修改弹出页面
function showlayer(url){
    layer.open({
        type: 2,
        title: '',
        shadeClose: true,
        shade: 0.8,
        area: ['50%', '80%'],
        content:url,
    });
}

//
/**
 * 列表页面设置启用和禁用
 * 参数说明:设置跳转路径变量：setStatusUrl
 */
$(function () {
    $('body').on('click','.setStatus_btn',function () {
        var id = $(this).data('id');
        var url = setStatusUrl;
        $.post(url, {id: id}, function (data) {
            if(data.code == 1){
                history.go(0);
            }
        }, "json");
        return false;
    });
});

//失败不跳转
function complete2(data) {
    if (data.code == 1) {
        layer.msg(data.msg, {icon: 6}, function (index) {
            layer.close(index);
            window.location.href = data.url;
        });
    } else {
        layer.alert(data.msg, {icon: 5}, function (index) {
            layer.close(index);
        });
    }
}
//导出Excel使用
$("#button").click(function () {
    // return false;
    var state = $('#state').val();
    $('#state_text').val(state);

    var leibie = $('#leibie').val();
    $('#leibie_text').val(leibie);

    var channel = $('#channel').val();
    $('#channel_text').val(channel);

    var source = $('#source').val();
    $('#source_text').val(source);

    var banji = $('#banji').val();
    $('#banji_text').val(banji);

    var xingqi = $('#xingqi').val();
    $('#xingqi_text').val(xingqi);

    var diqu = $('#diqu').val();
    $('#diqu_text').val(diqu);

    var jdry = $('#jdry').val();
    $('#jdry_text').val(jdry);

    var yykf = $('#yykf').val();
    $('#yykf_text').val(yykf);

    var mendian = $('#mendian').val();
    $('#mendian_text').val(mendian);

    var menshi = $('#menshi').val();
    $('#menshi_text').val(menshi);

    var shot_mode = $('#shot_mode').val();
    $('#shot_mode_text').val(shot_mode);

    var personnel = $('#personnel').val();
    $('#personnel_text').val(personnel);

    var invitation_group = $('#invitation_group').val();
    $('#invitation_group_text').val(invitation_group);

    var invitation = $('#invitation-personnel').val();
    $('#invitation-personnel_text').val(invitation);
    $("form").attr("action","/admin/daoru/daochu");
    $("form").attr("method","get");
    $('form').submit();
    //    setTimeout($("form").attr("action", "/admin/yewu/olist")
    //        , 5000);
});



